package com.mzj.saas.mservice.sys.repository;


import com.mzj.saas.mservice.sys.entity.User;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.data.repository.query.Param;

import java.util.Collection;
import java.util.List;

public interface UserRepository extends PagingAndSortingRepository<User, Long>, JpaSpecificationExecutor<User> {
    @Query("from User where mobile=:mobile and status != 2")
    User findByMobile(@Param("mobile") String mobile);

    @Query("from User where id=:Id and status != 2")
    User findById(@Param("Id") String Id);

    List<User> findByIdIn(List<String> ids);

    List<User> findByNameLike(String name);
    //List<User> findByDepId(Long depId);
//	@Query("from User where depId=:depId and status !=:status ")
//	List<User> findByDepIdAndStatus(@Param("depId") Long depId,@Param("status") Short status);
//	Integer countByDepIdInAndStatusIn(List<Long> ids,List<Short> status);

    @Query("from User where id=:Id")
    User findUserById(@Param("Id") String Id);

    List<User> findByIdInAndType(Collection<String> ids, short type);

}
